<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) Bartosz Nitka, Facebook 2015

-}</span><span>
</span><span id="line-5"></span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# LANGUAGE BangPatterns #-}</span><span>
</span><span id="line-7"></span><span>
</span><span id="line-8"></span><span class="hs-comment">-- | Utilities for efficiently and deterministically computing free variables.</span><span>
</span><span id="line-9"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Utils.FV</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-10"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Deterministic free vars computations</span></span><span>
</span><span id="line-11"></span><span>        </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier">FV</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#InterestingVarFun"><span class="hs-identifier">InterestingVarFun</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Running the computations</span></span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><a href="GHC.Utils.FV.html#fvVarList"><span class="hs-identifier">fvVarList</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#fvVarSet"><span class="hs-identifier">fvVarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#fvDVarSet"><span class="hs-identifier">fvDVarSet</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-15"></span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Manipulating those computations</span></span><span>
</span><span id="line-17"></span><span>        </span><span class="annot"><a href="GHC.Utils.FV.html#unitFV"><span class="hs-identifier">unitFV</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>        </span><span class="annot"><a href="GHC.Utils.FV.html#emptyFV"><span class="hs-identifier">emptyFV</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-19"></span><span>        </span><span class="annot"><a href="GHC.Utils.FV.html#mkFVs"><span class="hs-identifier">mkFVs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.Utils.FV.html#unionFV"><span class="hs-identifier">unionFV</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.Utils.FV.html#unionsFV"><span class="hs-identifier">unionsFV</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.Utils.FV.html#delFV"><span class="hs-identifier">delFV</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><a href="GHC.Utils.FV.html#delFVs"><span class="hs-identifier">delFVs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><a href="GHC.Utils.FV.html#filterFV"><span class="hs-identifier">filterFV</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><a href="GHC.Utils.FV.html#mapUnionFV"><span class="hs-identifier">mapUnionFV</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span class="hs-comment">-- | Predicate on possible free variables: returns @True@ iff the variable is</span><span>
</span><span id="line-34"></span><span class="hs-comment">-- interesting</span><span>
</span><span id="line-35"></span><span class="hs-keyword">type</span><span> </span><span id="InterestingVarFun"><span class="annot"><a href="GHC.Utils.FV.html#InterestingVarFun"><span class="hs-identifier hs-var">InterestingVarFun</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-comment">-- Note [Deterministic FV]</span><span>
</span><span id="line-38"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-39"></span><span class="hs-comment">-- When computing free variables, the order in which you get them affects</span><span>
</span><span id="line-40"></span><span class="hs-comment">-- the results of floating and specialization. If you use UniqFM to collect</span><span>
</span><span id="line-41"></span><span class="hs-comment">-- them and then turn that into a list, you get them in nondeterministic</span><span>
</span><span id="line-42"></span><span class="hs-comment">-- order as described in Note [Deterministic UniqFM] in GHC.Types.Unique.DFM.</span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span class="hs-comment">-- A naive algorithm for free variables relies on merging sets of variables.</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- Merging costs O(n+m) for UniqFM and for UniqDFM there's an additional log</span><span>
</span><span id="line-46"></span><span class="hs-comment">-- factor. It's cheaper to incrementally add to a list and use a set to check</span><span>
</span><span id="line-47"></span><span class="hs-comment">-- for duplicates.</span><span>
</span><span id="line-48"></span><span class="hs-keyword">type</span><span> </span><span id="FV"><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-var">FV</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#InterestingVarFun"><span class="hs-identifier hs-type">InterestingVarFun</span></a></span><span> </span><span class="hs-comment">-- Used for filtering sets as we build them</span><span>
</span><span id="line-49"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>           </span><span class="hs-comment">-- Locally bound variables</span><span>
</span><span id="line-50"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#VarAcc"><span class="hs-identifier hs-type">VarAcc</span></a></span><span>           </span><span class="hs-comment">-- Accumulator</span><span>
</span><span id="line-51"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#VarAcc"><span class="hs-identifier hs-type">VarAcc</span></a></span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span class="hs-keyword">type</span><span> </span><span id="VarAcc"><span class="annot"><a href="GHC.Utils.FV.html#VarAcc"><span class="hs-identifier hs-var">VarAcc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- List to preserve ordering and set to check for membership,</span><span>
</span><span id="line-54"></span><span>                               </span><span class="hs-comment">-- so that the list doesn't have duplicates</span><span>
</span><span id="line-55"></span><span>                               </span><span class="hs-comment">-- For explanation of why using `VarSet` is not deterministic see</span><span>
</span><span id="line-56"></span><span>                               </span><span class="hs-comment">-- Note [Deterministic UniqFM] in GHC.Types.Unique.DFM.</span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span class="hs-comment">-- Note [FV naming conventions]</span><span>
</span><span id="line-59"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-60"></span><span class="hs-comment">-- To get the performance and determinism that FV provides, FV computations</span><span>
</span><span id="line-61"></span><span class="hs-comment">-- need to built up from smaller FV computations and then evaluated with</span><span>
</span><span id="line-62"></span><span class="hs-comment">-- one of `fvVarList`, `fvDVarSet` That means the functions</span><span>
</span><span id="line-63"></span><span class="hs-comment">-- returning FV need to be exported.</span><span>
</span><span id="line-64"></span><span class="hs-comment">--</span><span>
</span><span id="line-65"></span><span class="hs-comment">-- The conventions are:</span><span>
</span><span id="line-66"></span><span class="hs-comment">--</span><span>
</span><span id="line-67"></span><span class="hs-comment">-- a) non-deterministic functions:</span><span>
</span><span id="line-68"></span><span class="hs-comment">--   * a function that returns VarSet</span><span>
</span><span id="line-69"></span><span class="hs-comment">--       e.g. `tyVarsOfType`</span><span>
</span><span id="line-70"></span><span class="hs-comment">-- b) deterministic functions:</span><span>
</span><span id="line-71"></span><span class="hs-comment">--   * a worker that returns FV</span><span>
</span><span id="line-72"></span><span class="hs-comment">--       e.g. `tyFVsOfType`</span><span>
</span><span id="line-73"></span><span class="hs-comment">--   * a function that returns [Var]</span><span>
</span><span id="line-74"></span><span class="hs-comment">--       e.g. `tyVarsOfTypeList`</span><span>
</span><span id="line-75"></span><span class="hs-comment">--   * a function that returns DVarSet</span><span>
</span><span id="line-76"></span><span class="hs-comment">--       e.g. `tyVarsOfTypeDSet`</span><span>
</span><span id="line-77"></span><span class="hs-comment">--</span><span>
</span><span id="line-78"></span><span class="hs-comment">-- Where tyVarsOfType, tyVarsOfTypeList, tyVarsOfTypeDSet are implemented</span><span>
</span><span id="line-79"></span><span class="hs-comment">-- in terms of the worker evaluated with fvVarSet, fvVarList, fvDVarSet</span><span>
</span><span id="line-80"></span><span class="hs-comment">-- respectively.</span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="hs-comment">-- | Run a free variable computation, returning a list of distinct free</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- variables in deterministic order and a non-deterministic set containing</span><span>
</span><span id="line-84"></span><span class="hs-comment">-- those variables.</span><span>
</span><span id="line-85"></span><span class="annot"><a href="GHC.Utils.FV.html#fvVarAcc"><span class="hs-identifier hs-type">fvVarAcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>  </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span id="fvVarAcc"><span class="annot"><span class="annottext">fvVarAcc :: FV -&gt; ([Var], VarSet)
</span><a href="GHC.Utils.FV.html#fvVarAcc"><span class="hs-identifier hs-var hs-var">fvVarAcc</span></a></span></span><span> </span><span id="local-6989586621680814316"><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680814316"><span class="hs-identifier hs-var">fv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680814316"><span class="hs-identifier hs-var">fv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Var -&gt; Bool
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="hs-comment">-- | Run a free variable computation, returning a list of distinct free</span><span>
</span><span id="line-89"></span><span class="hs-comment">-- variables in deterministic order.</span><span>
</span><span id="line-90"></span><span class="annot"><a href="GHC.Utils.FV.html#fvVarList"><span class="hs-identifier hs-type">fvVarList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-91"></span><span id="fvVarList"><span class="annot"><span class="annottext">fvVarList :: FV -&gt; [Var]
</span><a href="GHC.Utils.FV.html#fvVarList"><span class="hs-identifier hs-var hs-var">fvVarList</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Var], VarSet) -&gt; [Var]
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">(([Var], VarSet) -&gt; [Var])
-&gt; (FV -&gt; ([Var], VarSet)) -&gt; FV -&gt; [Var]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FV -&gt; ([Var], VarSet)
</span><a href="GHC.Utils.FV.html#fvVarAcc"><span class="hs-identifier hs-var">fvVarAcc</span></a></span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="hs-comment">-- | Run a free variable computation, returning a deterministic set of free</span><span>
</span><span id="line-94"></span><span class="hs-comment">-- variables. Note that this is just a wrapper around the version that</span><span>
</span><span id="line-95"></span><span class="hs-comment">-- returns a deterministic list. If you need a list you should use</span><span>
</span><span id="line-96"></span><span class="hs-comment">-- `fvVarList`.</span><span>
</span><span id="line-97"></span><span class="annot"><a href="GHC.Utils.FV.html#fvDVarSet"><span class="hs-identifier hs-type">fvDVarSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DVarSet"><span class="hs-identifier hs-type">DVarSet</span></a></span><span>
</span><span id="line-98"></span><span id="fvDVarSet"><span class="annot"><span class="annottext">fvDVarSet :: FV -&gt; DVarSet
</span><a href="GHC.Utils.FV.html#fvDVarSet"><span class="hs-identifier hs-var hs-var">fvDVarSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Var] -&gt; DVarSet
</span><a href="GHC.Types.Var.Set.html#mkDVarSet"><span class="hs-identifier hs-var">mkDVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">([Var] -&gt; DVarSet) -&gt; (FV -&gt; [Var]) -&gt; FV -&gt; DVarSet
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FV -&gt; [Var]
</span><a href="GHC.Utils.FV.html#fvVarList"><span class="hs-identifier hs-var">fvVarList</span></a></span><span>
</span><span id="line-99"></span><span>
</span><span id="line-100"></span><span class="hs-comment">-- | Run a free variable computation, returning a non-deterministic set of</span><span>
</span><span id="line-101"></span><span class="hs-comment">-- free variables. Don't use if the set will be later converted to a list</span><span>
</span><span id="line-102"></span><span class="hs-comment">-- and the order of that list will impact the generated code.</span><span>
</span><span id="line-103"></span><span class="annot"><a href="GHC.Utils.FV.html#fvVarSet"><span class="hs-identifier hs-type">fvVarSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-104"></span><span id="fvVarSet"><span class="annot"><span class="annottext">fvVarSet :: FV -&gt; VarSet
</span><a href="GHC.Utils.FV.html#fvVarSet"><span class="hs-identifier hs-var hs-var">fvVarSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Var], VarSet) -&gt; VarSet
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">(([Var], VarSet) -&gt; VarSet)
-&gt; (FV -&gt; ([Var], VarSet)) -&gt; FV -&gt; VarSet
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FV -&gt; ([Var], VarSet)
</span><a href="GHC.Utils.FV.html#fvVarAcc"><span class="hs-identifier hs-var">fvVarAcc</span></a></span><span>
</span><span id="line-105"></span><span>
</span><span id="line-106"></span><span class="hs-comment">-- Note [FV eta expansion]</span><span>
</span><span id="line-107"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-108"></span><span class="hs-comment">-- Let's consider an eta-reduced implementation of freeVarsOf using FV:</span><span>
</span><span id="line-109"></span><span class="hs-comment">--</span><span>
</span><span id="line-110"></span><span class="hs-comment">-- freeVarsOf (App a b) = freeVarsOf a `unionFV` freeVarsOf b</span><span>
</span><span id="line-111"></span><span class="hs-comment">--</span><span>
</span><span id="line-112"></span><span class="hs-comment">-- If GHC doesn't eta-expand it, after inlining unionFV we end up with</span><span>
</span><span id="line-113"></span><span class="hs-comment">--</span><span>
</span><span id="line-114"></span><span class="hs-comment">-- freeVarsOf = \x -&gt;</span><span>
</span><span id="line-115"></span><span class="hs-comment">--   case x of</span><span>
</span><span id="line-116"></span><span class="hs-comment">--     App a b -&gt; \fv_cand in_scope acc -&gt;</span><span>
</span><span id="line-117"></span><span class="hs-comment">--       freeVarsOf a fv_cand in_scope $! freeVarsOf b fv_cand in_scope $! acc</span><span>
</span><span id="line-118"></span><span class="hs-comment">--</span><span>
</span><span id="line-119"></span><span class="hs-comment">-- which has to create a thunk, resulting in more allocations.</span><span>
</span><span id="line-120"></span><span class="hs-comment">--</span><span>
</span><span id="line-121"></span><span class="hs-comment">-- On the other hand if it is eta-expanded:</span><span>
</span><span id="line-122"></span><span class="hs-comment">--</span><span>
</span><span id="line-123"></span><span class="hs-comment">-- freeVarsOf (App a b) fv_cand in_scope acc =</span><span>
</span><span id="line-124"></span><span class="hs-comment">--   (freeVarsOf a `unionFV` freeVarsOf b) fv_cand in_scope acc</span><span>
</span><span id="line-125"></span><span class="hs-comment">--</span><span>
</span><span id="line-126"></span><span class="hs-comment">-- after inlining unionFV we have:</span><span>
</span><span id="line-127"></span><span class="hs-comment">--</span><span>
</span><span id="line-128"></span><span class="hs-comment">-- freeVarsOf = \x fv_cand in_scope acc -&gt;</span><span>
</span><span id="line-129"></span><span class="hs-comment">--   case x of</span><span>
</span><span id="line-130"></span><span class="hs-comment">--     App a b -&gt;</span><span>
</span><span id="line-131"></span><span class="hs-comment">--       freeVarsOf a fv_cand in_scope $! freeVarsOf b fv_cand in_scope $! acc</span><span>
</span><span id="line-132"></span><span class="hs-comment">--</span><span>
</span><span id="line-133"></span><span class="hs-comment">-- which saves allocations.</span><span>
</span><span id="line-134"></span><span class="hs-comment">--</span><span>
</span><span id="line-135"></span><span class="hs-comment">-- GHC when presented with knowledge about all the call sites, correctly</span><span>
</span><span id="line-136"></span><span class="hs-comment">-- eta-expands in this case. Unfortunately due to the fact that freeVarsOf gets</span><span>
</span><span id="line-137"></span><span class="hs-comment">-- exported to be composed with other functions, GHC doesn't have that</span><span>
</span><span id="line-138"></span><span class="hs-comment">-- information and has to be more conservative here.</span><span>
</span><span id="line-139"></span><span class="hs-comment">--</span><span>
</span><span id="line-140"></span><span class="hs-comment">-- Hence functions that get exported and return FV need to be manually</span><span>
</span><span id="line-141"></span><span class="hs-comment">-- eta-expanded. See also #11146.</span><span>
</span><span id="line-142"></span><span>
</span><span id="line-143"></span><span class="hs-comment">-- | Add a variable - when free, to the returned free variables.</span><span>
</span><span id="line-144"></span><span class="hs-comment">-- Ignores duplicates and respects the filtering function.</span><span>
</span><span id="line-145"></span><span class="annot"><a href="GHC.Utils.FV.html#unitFV"><span class="hs-identifier hs-type">unitFV</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span>
</span><span id="line-146"></span><span id="unitFV"><span class="annot"><span class="annottext">unitFV :: Var -&gt; FV
</span><a href="GHC.Utils.FV.html#unitFV"><span class="hs-identifier hs-var hs-var">unitFV</span></a></span></span><span> </span><span id="local-6989586621680814310"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621680814310"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span id="local-6989586621680814309"><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814309"><span class="hs-identifier hs-var">fv_cand</span></a></span></span><span> </span><span id="local-6989586621680814308"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814308"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680814307"><span class="annot"><span class="annottext">acc :: ([Var], VarSet)
</span><a href="#local-6989586621680814307"><span class="hs-identifier hs-var">acc</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621680814306"><span class="annot"><span class="annottext">[Var]
</span><a href="#local-6989586621680814306"><span class="hs-identifier hs-var">have</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680814305"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814305"><span class="hs-identifier hs-var">haveSet</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-147"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621680814310"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="annot"><span class="annottext">Var -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814308"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814307"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-148"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621680814310"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="annot"><span class="annottext">Var -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814305"><span class="hs-identifier hs-var">haveSet</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814307"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-149"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814309"><span class="hs-identifier hs-var">fv_cand</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621680814310"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621680814310"><span class="hs-identifier hs-var">var</span></a></span><span class="annot"><span class="annottext">Var -&gt; [Var] -&gt; [Var]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Var]
</span><a href="#local-6989586621680814306"><span class="hs-identifier hs-var">have</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; Var -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-identifier hs-var">extendVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814305"><span class="hs-identifier hs-var">haveSet</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621680814310"><span class="hs-identifier hs-var">var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-150"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814307"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-151"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#unitFV"><span class="hs-pragma hs-type">unitFV</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-152"></span><span>
</span><span id="line-153"></span><span class="hs-comment">-- | Return no free variables.</span><span>
</span><span id="line-154"></span><span class="annot"><a href="GHC.Utils.FV.html#emptyFV"><span class="hs-identifier hs-type">emptyFV</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span>
</span><span id="line-155"></span><span id="emptyFV"><span class="annot"><span class="annottext">emptyFV :: FV
</span><a href="GHC.Utils.FV.html#emptyFV"><span class="hs-identifier hs-var hs-var">emptyFV</span></a></span></span><span> </span><span class="annot"><span class="annottext">Var -&gt; Bool
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680814302"><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814302"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814302"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-156"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#emptyFV"><span class="hs-pragma hs-type">emptyFV</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-157"></span><span>
</span><span id="line-158"></span><span class="hs-comment">-- | Union two free variable computations.</span><span>
</span><span id="line-159"></span><span class="annot"><a href="GHC.Utils.FV.html#unionFV"><span class="hs-identifier hs-type">unionFV</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span>
</span><span id="line-160"></span><span id="unionFV"><span class="annot"><span class="annottext">unionFV :: FV -&gt; FV -&gt; FV
</span><a href="GHC.Utils.FV.html#unionFV"><span class="hs-identifier hs-var hs-var">unionFV</span></a></span></span><span> </span><span id="local-6989586621680814301"><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680814301"><span class="hs-identifier hs-var">fv1</span></a></span></span><span> </span><span id="local-6989586621680814300"><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680814300"><span class="hs-identifier hs-var">fv2</span></a></span></span><span> </span><span id="local-6989586621680814299"><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814299"><span class="hs-identifier hs-var">fv_cand</span></a></span></span><span> </span><span id="local-6989586621680814298"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814298"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680814297"><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814297"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-161"></span><span>  </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680814301"><span class="hs-identifier hs-var">fv1</span></a></span><span> </span><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814299"><span class="hs-identifier hs-var">fv_cand</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814298"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">(([Var], VarSet) -&gt; ([Var], VarSet))
-&gt; ([Var], VarSet) -&gt; ([Var], VarSet)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680814300"><span class="hs-identifier hs-var">fv2</span></a></span><span> </span><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814299"><span class="hs-identifier hs-var">fv_cand</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814298"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">(([Var], VarSet) -&gt; ([Var], VarSet))
-&gt; ([Var], VarSet) -&gt; ([Var], VarSet)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814297"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-162"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#unionFV"><span class="hs-pragma hs-type">unionFV</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-163"></span><span>
</span><span id="line-164"></span><span class="hs-comment">-- | Mark the variable as not free by putting it in scope.</span><span>
</span><span id="line-165"></span><span class="annot"><a href="GHC.Utils.FV.html#delFV"><span class="hs-identifier hs-type">delFV</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span>
</span><span id="line-166"></span><span id="delFV"><span class="annot"><span class="annottext">delFV :: Var -&gt; FV -&gt; FV
</span><a href="GHC.Utils.FV.html#delFV"><span class="hs-identifier hs-var hs-var">delFV</span></a></span></span><span> </span><span id="local-6989586621680814295"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621680814295"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span id="local-6989586621680814294"><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680814294"><span class="hs-identifier hs-var">fv</span></a></span></span><span> </span><span id="local-6989586621680814293"><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814293"><span class="hs-identifier hs-var">fv_cand</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680814292"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814292"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680814291"><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814291"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-167"></span><span>  </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680814294"><span class="hs-identifier hs-var">fv</span></a></span><span> </span><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814293"><span class="hs-identifier hs-var">fv_cand</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Var -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-identifier hs-var">extendVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814292"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621680814295"><span class="hs-identifier hs-var">var</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814291"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-168"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#delFV"><span class="hs-pragma hs-type">delFV</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-169"></span><span>
</span><span id="line-170"></span><span class="hs-comment">-- | Mark many free variables as not free.</span><span>
</span><span id="line-171"></span><span class="annot"><a href="GHC.Utils.FV.html#delFVs"><span class="hs-identifier hs-type">delFVs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span>
</span><span id="line-172"></span><span id="delFVs"><span class="annot"><span class="annottext">delFVs :: VarSet -&gt; FV -&gt; FV
</span><a href="GHC.Utils.FV.html#delFVs"><span class="hs-identifier hs-var hs-var">delFVs</span></a></span></span><span> </span><span id="local-6989586621680814290"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814290"><span class="hs-identifier hs-var">vars</span></a></span></span><span> </span><span id="local-6989586621680814289"><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680814289"><span class="hs-identifier hs-var">fv</span></a></span></span><span> </span><span id="local-6989586621680814288"><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814288"><span class="hs-identifier hs-var">fv_cand</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680814287"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814287"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680814286"><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814286"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-173"></span><span>  </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680814289"><span class="hs-identifier hs-var">fv</span></a></span><span> </span><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814288"><span class="hs-identifier hs-var">fv_cand</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814287"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814290"><span class="hs-identifier hs-var">vars</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814286"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-174"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#delFVs"><span class="hs-pragma hs-type">delFVs</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span class="hs-comment">-- | Filter a free variable computation.</span><span>
</span><span id="line-177"></span><span class="annot"><a href="GHC.Utils.FV.html#filterFV"><span class="hs-identifier hs-type">filterFV</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#InterestingVarFun"><span class="hs-identifier hs-type">InterestingVarFun</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span>
</span><span id="line-178"></span><span id="filterFV"><span class="annot"><span class="annottext">filterFV :: (Var -&gt; Bool) -&gt; FV -&gt; FV
</span><a href="GHC.Utils.FV.html#filterFV"><span class="hs-identifier hs-var hs-var">filterFV</span></a></span></span><span> </span><span id="local-6989586621680814284"><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814284"><span class="hs-identifier hs-var">fv_cand2</span></a></span></span><span> </span><span id="local-6989586621680814283"><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680814283"><span class="hs-identifier hs-var">fv</span></a></span></span><span> </span><span id="local-6989586621680814282"><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814282"><span class="hs-identifier hs-var">fv_cand1</span></a></span></span><span> </span><span id="local-6989586621680814281"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814281"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680814280"><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814280"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-179"></span><span>  </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680814283"><span class="hs-identifier hs-var">fv</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680814279"><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621680814279"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814282"><span class="hs-identifier hs-var">fv_cand1</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621680814279"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814284"><span class="hs-identifier hs-var">fv_cand2</span></a></span><span> </span><span class="annot"><span class="annottext">Var
</span><a href="#local-6989586621680814279"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814281"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814280"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-180"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#filterFV"><span class="hs-pragma hs-type">filterFV</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-181"></span><span>
</span><span id="line-182"></span><span class="hs-comment">-- | Map a free variable computation over a list and union the results.</span><span>
</span><span id="line-183"></span><span id="local-6989586621680814334"><span class="annot"><a href="GHC.Utils.FV.html#mapUnionFV"><span class="hs-identifier hs-type">mapUnionFV</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680814334"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680814334"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span></span><span>
</span><span id="line-184"></span><span id="mapUnionFV"><span class="annot"><span class="annottext">mapUnionFV :: forall a. (a -&gt; FV) -&gt; [a] -&gt; FV
</span><a href="GHC.Utils.FV.html#mapUnionFV"><span class="hs-identifier hs-var hs-var">mapUnionFV</span></a></span></span><span> </span><span id="local-6989586621680814277"><span class="annot"><span class="annottext">a -&gt; FV
</span><a href="#local-6989586621680814277"><span class="hs-identifier hs-var">_f</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621680814276"><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814276"><span class="hs-identifier hs-var">_fv_cand</span></a></span></span><span> </span><span id="local-6989586621680814275"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814275"><span class="hs-identifier hs-var">_in_scope</span></a></span></span><span> </span><span id="local-6989586621680814274"><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814274"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814274"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-185"></span><span class="annot"><a href="GHC.Utils.FV.html#mapUnionFV"><span class="hs-identifier hs-var">mapUnionFV</span></a></span><span> </span><span id="local-6989586621680814273"><span class="annot"><span class="annottext">a -&gt; FV
</span><a href="#local-6989586621680814273"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680814272"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680814272"><span class="hs-identifier hs-var">a</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680814271"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680814271"><span class="hs-keyword hs-var">as</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680814270"><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814270"><span class="hs-identifier hs-var">fv_cand</span></a></span></span><span> </span><span id="local-6989586621680814269"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814269"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680814268"><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814268"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-186"></span><span>  </span><span class="annot"><span class="annottext">(a -&gt; FV) -&gt; [a] -&gt; FV
forall a. (a -&gt; FV) -&gt; [a] -&gt; FV
</span><a href="GHC.Utils.FV.html#mapUnionFV"><span class="hs-identifier hs-var">mapUnionFV</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; FV
</span><a href="#local-6989586621680814273"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680814271"><span class="hs-keyword hs-var">as</span></a></span><span> </span><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814270"><span class="hs-identifier hs-var">fv_cand</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814269"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">(([Var], VarSet) -&gt; ([Var], VarSet))
-&gt; ([Var], VarSet) -&gt; ([Var], VarSet)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; FV
</span><a href="#local-6989586621680814273"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680814272"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814270"><span class="hs-identifier hs-var">fv_cand</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814269"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">(([Var], VarSet) -&gt; ([Var], VarSet))
-&gt; ([Var], VarSet) -&gt; ([Var], VarSet)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814268"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-187"></span><span class="hs-pragma">{-# INLINABLE</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#mapUnionFV"><span class="hs-pragma hs-type">mapUnionFV</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-188"></span><span>
</span><span id="line-189"></span><span class="hs-comment">-- | Union many free variable computations.</span><span>
</span><span id="line-190"></span><span class="annot"><a href="GHC.Utils.FV.html#unionsFV"><span class="hs-identifier hs-type">unionsFV</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span>
</span><span id="line-191"></span><span id="unionsFV"><span class="annot"><span class="annottext">unionsFV :: [FV] -&gt; FV
</span><a href="GHC.Utils.FV.html#unionsFV"><span class="hs-identifier hs-var hs-var">unionsFV</span></a></span></span><span> </span><span id="local-6989586621680814267"><span class="annot"><span class="annottext">[FV]
</span><a href="#local-6989586621680814267"><span class="hs-identifier hs-var">fvs</span></a></span></span><span> </span><span id="local-6989586621680814266"><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814266"><span class="hs-identifier hs-var">fv_cand</span></a></span></span><span> </span><span id="local-6989586621680814265"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814265"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680814264"><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814264"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(FV -&gt; FV) -&gt; [FV] -&gt; FV
forall a. (a -&gt; FV) -&gt; [a] -&gt; FV
</span><a href="GHC.Utils.FV.html#mapUnionFV"><span class="hs-identifier hs-var">mapUnionFV</span></a></span><span> </span><span class="annot"><span class="annottext">FV -&gt; FV
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">[FV]
</span><a href="#local-6989586621680814267"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814266"><span class="hs-identifier hs-var">fv_cand</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814265"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814264"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-192"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#unionsFV"><span class="hs-pragma hs-type">unionsFV</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-193"></span><span>
</span><span id="line-194"></span><span class="hs-comment">-- | Add multiple variables - when free, to the returned free variables.</span><span>
</span><span id="line-195"></span><span class="hs-comment">-- Ignores duplicates and respects the filtering function.</span><span>
</span><span id="line-196"></span><span class="annot"><a href="GHC.Utils.FV.html#mkFVs"><span class="hs-identifier hs-type">mkFVs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span>
</span><span id="line-197"></span><span id="mkFVs"><span class="annot"><span class="annottext">mkFVs :: [Var] -&gt; FV
</span><a href="GHC.Utils.FV.html#mkFVs"><span class="hs-identifier hs-var hs-var">mkFVs</span></a></span></span><span> </span><span id="local-6989586621680814262"><span class="annot"><span class="annottext">[Var]
</span><a href="#local-6989586621680814262"><span class="hs-identifier hs-var">vars</span></a></span></span><span> </span><span id="local-6989586621680814261"><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814261"><span class="hs-identifier hs-var">fv_cand</span></a></span></span><span> </span><span id="local-6989586621680814260"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814260"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680814259"><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814259"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-198"></span><span>  </span><span class="annot"><span class="annottext">(Var -&gt; FV) -&gt; [Var] -&gt; FV
forall a. (a -&gt; FV) -&gt; [a] -&gt; FV
</span><a href="GHC.Utils.FV.html#mapUnionFV"><span class="hs-identifier hs-var">mapUnionFV</span></a></span><span> </span><span class="annot"><span class="annottext">Var -&gt; FV
</span><a href="GHC.Utils.FV.html#unitFV"><span class="hs-identifier hs-var">unitFV</span></a></span><span> </span><span class="annot"><span class="annottext">[Var]
</span><a href="#local-6989586621680814262"><span class="hs-identifier hs-var">vars</span></a></span><span> </span><span class="annot"><span class="annottext">Var -&gt; Bool
</span><a href="#local-6989586621680814261"><span class="hs-identifier hs-var">fv_cand</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680814260"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">([Var], VarSet)
</span><a href="#local-6989586621680814259"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-199"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#mkFVs"><span class="hs-pragma hs-type">mkFVs</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-200"></span></pre></body></html>